<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>     
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>   
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<c:choose>
	 <c:when test="${os eq 'wechat'|| os eq 'web'}">
		<link rel="stylesheet"  href="${host_url}/css/app/common.css">
		<link rel="stylesheet"  href="${host_url}/css/app/coupon_details.css">
		<link rel="stylesheet"  href="${host_url}/css/app/dropload.css">
		<script src="${host_url}/js/app/commonForWe.js"></script>
		<script src="${host_url}/js/app/dropload.min.js"></script> 	 	 
	 </c:when>
	 <c:otherwise>
		 <script src="/js/app/common.js"></script>
		 <link rel="stylesheet"  href="/css/app/common.css">
		 <link rel="stylesheet"  href="/css/app/coupon_details.css">
		 <link rel="stylesheet"  href="/css/app/dropload.css">
		 <script src="/js/app/jquery.min.js"></script>
		 <script src="/js/app/common.js"></script>
		 <script src="/js/app/dropload.min.js"></script> 
	 </c:otherwise>
</c:choose>


<script type="text/javascript">
  document.getElementsByTagName('html')[0].style.fontSize = document.documentElement.clientWidth/50 + 'px';
  var os="${os}";
  <c:if test="${os=='wechat'||os=='web'}">
	  function getList(bill_type,award_id,type){
			$.ajax({
				type:"GET", 
				url:'incomeAndExpensesList.do?bill_type='+bill_type+"&award_id="+award_id+"&type="+type,
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					$("#we_body").html(data);
					var page_index_select = 2;	/* 筛选 */
					loadPagination("listSelect",page_index_select,"logSelect",bill_type,type,award_id);
				 },	 
			});
		  }   
		
		$(function(){
			$.ajax({
				type:"GET", 	
				url:'incomeAndExpensesItem.do?bill_type=2',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logIn").html(data);  
					}else{
						$("#listInBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
			
			$.ajax({
				type:"GET", 	
				url:'incomeAndExpensesItem.do?bill_type=1',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logOut").html(data);  
					}else{
						$("#listOutBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
		});
	 
		
		$(function(){
			/* 页数 */
			var page_index_all = 2; /* 全部 */
			var page_index_in = 2;	/* 收入 */
			var page_index_out = 2;	/* 支出 */
			
			/*  dropload 加载分页 */
			loadPagination("listAll",page_index_all,"logAll","","","");
			loadPagination("listIn",page_index_in,"logIn",2,"","");
			loadPagination("listOut",page_index_out,"logOut",1,"","");
		});	

		function loadPagination(div_id, page_index, ul_id, bill_type, type,award_id){
			
			$('#'+div_id).dropload({
				scrollArea : window,
				loadDownFn : function(me){
					$.ajax({
						type: 'get',
						url: 'incomeAndExpensesItem.do?page_index='+page_index+"&bill_type="+bill_type+"&type="+type+"&award_id="+award_id,
						dataType: 'text',
						beforeSend: function(request) {
							request.setRequestHeader("AUTHORIZATION","${token}");
							request.setRequestHeader("SECRET","${memberId}");
							request.setRequestHeader("OS","${os}");
						 }, 
						contentType:"application/x-www-form-urlencoded; charset=UTF-8",
						success: function(msg){
							if($.trim(msg)){
								page_index++;
								$("#"+ul_id).append(msg);
								me.resetload();
							 /* 如果没有数据 */
							} else{
								/*  锁定 */
								me.lock();
								/* 无数据 */
								me.noData();
								$("#"+div_id+" .dropload-load").html("");
							} 
						},
							error: function(xhr, type){
							/* 即使加载出错，也得重置 */
							me.resetload();
						} 
					});
				}
			});
		}	
	 </c:if>
	 <c:if test="${os=='ios'|| os=='android'}">
	/* ios  android */
	  function GetToken(id){
		  var incomeAndExpensesLogOne_url = $("#incomeAndExpensesLogOne_url").val();
			 window.webkit.messageHandlers.ios_open_page.postMessage('WKViewController:::url->'+incomeAndExpensesLogOne_url+'?incomeAndExpenses_id='+id+':::webTitle->交易明细:::isRefresh->YES');
	  }  
	  
	  function getList(bill_type,award_id,type){
			$.ajax({
				type:"GET", 
				url:'incomeAndExpensesList?bill_type='+bill_type+"&award_id="+award_id+"&type="+type,
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					$("body").html(data);
					var page_index_select = 2;	/* 筛选 */
					loadPagination("listSelect",page_index_select,"logSelect",bill_type,type,award_id);
				 },	 
			});
		  }   
		
		$(function(){
			$.ajax({
				type:"GET", 	
				url:'incomeAndExpensesItem?bill_type=2',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logIn").html(data);  
					}else{
						$("#listInBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
			
			$.ajax({
				type:"GET", 	
				url:'incomeAndExpensesItem?bill_type=1',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logOut").html(data);  
					}else{
						$("#listOutBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
		});
	 
		
		$(function(){
			/* 页数 */
			var page_index_all = 2; /* 全部 */
			var page_index_in = 2;	/* 收入 */
			var page_index_out = 2;	/* 支出 */
			
			/* dropload 加载分页 */
			loadPagination("listAll",page_index_all,"logAll","","","");
			loadPagination("listIn",page_index_in,"logIn",2,"","");
			loadPagination("listOut",page_index_out,"logOut",1,"","");
		});	

		function loadPagination(div_id, page_index, ul_id, bill_type, type,award_id){
			
			$('#'+div_id).dropload({
				scrollArea : window,
				loadDownFn : function(me){
					$.ajax({
						type: 'get',
						url: 'incomeAndExpensesItem?page_index='+page_index+"&bill_type="+bill_type+"&type="+type+"&award_id="+award_id,
						dataType: 'text',
						beforeSend: function(request) {
							request.setRequestHeader("AUTHORIZATION","${token}");
							request.setRequestHeader("SECRET","${memberId}");
							request.setRequestHeader("OS","${os}");
						 }, 
						contentType:"application/x-www-form-urlencoded; charset=UTF-8",
						success: function(msg){
							if($.trim(msg)){
								page_index++;
								$("#"+ul_id).append(msg);
								me.resetload();
							 /* 如果没有数据 */
							} else{
								/* 锁定 */
								me.lock();
								/* 无数据 */
								me.noData();
								$("#"+div_id+" .dropload-load").html("");
							} 
						},
							error: function(xhr, type){
							/* 即使加载出错，也得重置 */
							me.resetload();
						} 
					});
				}
			});
		}	
		</c:if>
		
		$(function(){
			if('${incom_change}'=='1'){
					 $("#change_income").addClass('on');   
					 $("#listIn").css('display','block');
					 $("#listAll").css('display','none');
			}else{
				 $("#change_li").children(":first").addClass('on');   
			}
		});	
</script>
<title>list</title>
</head>
<body style="font-size:14px;">
<c:if test="${'wechat'==os ||'web'==os}">
	<div id="we_body">
</c:if>
<input type="hidden"  id="incomeAndExpensesLogOne_url" value="${incomeAndExpensesLogOne_url }">
    <div id="main">
        <div class="tab">
            <ul class="menu-group-center" id="change_li">
                <li>全部</li>
                <li id="change_income">收入</li>
                <li>支出</li>
                <p class="btn-popup"><span class="btn-popup">筛选</span></p>
            </ul>
            <div class="content" id="listAll">
                <ul id="logAll">
               	 	<c:forEach items="${incomeAndExpensesList}" var="c">
               	 	<c:if test="${c.free_cash != 0.00 }">
	                     <c:if test="${'ios'==os}">
					   		 <li class="clearfix" onclick="GetToken(${c.income_and_expenses_id})">
			             </c:if>
	                     <c:if test="${'wechat'==os ||'web'==os}">
					   		 <li class="clearfix" onclick="GetDetail('${c.income_and_expenses_id}')">
			             </c:if>
			    	     <c:if test="${'android'==os}">
			            	<li class="clearfix" onclick="android.startUrl('交易明细','${incomeAndExpensesLogOne_url}','incomeAndExpenses_id->${c.income_and_expenses_id}')">
			             </c:if>
			                <p class="leftArea">
		                       	<c:if test="${c.type==1 and c.pay_type ==null}"><span>离线充值</span><br></c:if>
		                       	<c:if test="${c.type==1 and c.pay_type !=null}"><span>余额充值</span><br></c:if>
		                       	<c:if test="${c.type==2 }"><span>${c.award_name }</span><br></c:if>
		                       	<c:if test="${c.type==3 }"><span>退款</span><br></c:if>
		                       	<c:if test="${c.type==4 and c.state == 2 and c.log_cash_draw_state == 0}"><span>余额提现(提现中)</span><br></c:if>  
				                <c:if test="${c.type==4 and c.state == 2 and c.log_cash_draw_state ==1}"><span>余额提现</span><br></c:if> 
				                <c:if test="${c.type==4 and c.state == 2 and c.log_cash_draw_state ==2}"><span>余额提现(提现失败)</span><br></c:if>  
		                       	<c:if test="${c.type==5 }"><span>购物&nbsp;（订单号：${c.order_no}）</span><br></c:if>
		                       	<c:if test="${c.type==6 }"><span>${ticket_name}充值</span><br></c:if>
	                        	<fmt:parseDate value=" ${c.create_time}" var="date" pattern="yyyy-MM-dd HH:mm:ss"/>  
				  				<span><fmt:formatDate value="${date}" pattern="yyyy-MM-dd HH:mm" /></span>  
	                        </p>
	                        <p class="rightArea <c:if test="${c.bill_type == 2 }">col-arresting</c:if>">
		                        <c:if test="${c.bill_type == 1 }">-</c:if>
		                        <c:if test="${c.bill_type == 2 }">+</c:if>
		                        <c:if test="${memberId !='758' }"> 
		                           <fmt:formatNumber value="${c.free_cash-c.special_pay_back}" pattern="#0.00" maxFractionDigits="2"/>
								</c:if> 
								<c:if test="${memberId =='758' }"> 
		                           <fmt:formatNumber value="${c.free_cash}" pattern="#0.00" maxFractionDigits="2"/>
								</c:if> 
	                        </p>
	                    </li>
                    </c:if>
                	</c:forEach>	
                </ul>
                <c:if test="${incomeAndExpensesList.size()==0}">
					<div class="zanwu">
						  <span><img src="/img/app/zanwu.png"></span>
						  <p>暂无记录</p>
					</div>
				</c:if> 
            </div>
 			<div class="content"  id="listIn" style="display: none;"><ul id="logIn"></ul>
	 			<div id="listInBlank">
					 
				</div>
 			</div>        
            <div class="content"  id="listOut" style="display: none;"><ul id="logOut"></ul>
	            <div id="listOutBlank">
					   
				</div>
            </div> 
        </div>
    </div>
	<div class="bg-popup"></div>
    <div id="popup">
        <div class="popup-content">
            <div class="clearfix"><h4 class="leftArea"><span>请选择您要筛选的分类</span></h4><p class="rightArea"><span>筛选</span></p></div>
            <ul class="one whole common">
                <li class="whole-one"><span>全部</span></li>
                <li><span>收入</span></li>
                <li><span>支出</span></li>
            </ul>
            <ul class="show-content">
                <li class="whole-one" onclick="getList('','','')"><span>全部</span></li>
                <li class="whole-two" onclick="getList(2,'','')"><span>收入</span></li>
                <li class="whole-there" onclick="getList(1,'','')"><span>支出</span></li>
            </ul>
            <ul class="show-content">
                <li class="whole-one" onclick="getList(2,'',1)"><span>余额充值</span></li>
                <c:if test="${awardList.size()>0}">
	                <c:forEach items="${awardList}" var="c">
	                	<li class="whole-two" onclick="getList(2,${c.awardId},2)"><span>${c.name}</span></li>
	                </c:forEach>
                </c:if>
                <li class="whole-two" onclick="getList(2,'',3)"><span>退款</span></li>
            </ul>
            <ul class="show-content">
                <li class="whole-one" onclick="getList(1,'',4)"><span>余额提现</span></li>
                <li class="whole-two" onclick="getList(1,'',5)" style="width:88%;"><span>购物</span></li>
                <li class="whole-one" onclick="getList(1,'',6)"><span>${ticket_name}充值</span></li>
            </ul>
        </div>
    </div>
 <c:if test="${'wechat'==os ||'web'==os}">
  	</div>
 </c:if>
</body>
</html>